package com.io.example.demoparent.queue;

import java.util.Scanner;

/**
 * 环形队列demo
 */
public class CircleArrayQueueDemo {

    public static void main(String[] args) {
        CircleQueue circleQueue = new CircleQueue(3);
        char key=' ';
        Scanner scanner = new Scanner(System.in);
        boolean loop=true;
        while (loop){
            System.out.println("s(show): 显示队列");
            System.out.println("e(exit): 退出队列");
            System.out.println("a(add): 添加数据到队列");
            System.out.println("g(get): 从队列中获取数据");
            System.out.println("k(keep): 查看队列头数据");
            key=scanner.next().charAt(0);
            switch (key){
                case 's':
                    circleQueue.showQueue();
                    break;
                case 'e':
                    loop=false;
                    break;
                case 'a':
                    System.out.println("输出一个数");
                    int anInt = scanner.nextInt();
                    circleQueue.addQueue(anInt);
                    break;
                case 'g':
                    int queue = circleQueue.getQueue();
                    System.out.println(queue);
                    break;
                case 'k':
                    int peekQueue = circleQueue.peekQueue();
                    System.out.println(peekQueue);
                    break;
                default:
                    break;

            }
        }
    }

}

